package com.example.myapplication;
import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;
import java.util.List;
import butterknife.BindView;
import butterknife.ButterKnife;
public class ListViewAdapter extends BaseAdapter {
    private List<String> mList;
    private Context context;
    ListViewAdapter(List<String> mList, Context context) {
        this.mList = mList;
        this.context = context;
    }
    public int getCount() {
        return mList.size();
    }
    @Override
    public Object getItem(int i) {
        return mList.get(i);
    }
    @Override
    public long getItemId(int i) {
        return i;
    }
    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {
        ViewHolder viewHolder;
        if (view == null) {
            view = View.inflate(context, R.layout.layout, null);
            viewHolder = new ViewHolder(view);
            view.setTag(viewHolder);
        } else {
            viewHolder = (ViewHolder) view.getTag();
        }
        viewHolder.mTextView.setText(mList.get(i));
        return view;
    }

    class ViewHolder {
        @BindView(R.id.layout_tv)
        TextView mTextView;
        ViewHolder(View view) {
            ButterKnife.bind(this, view);
        }
    }
}